package com.helloags;

import java.io.IOException;
import java.net.UnknownHostException;

import com.esri.arcgis.carto.MapDocument;
import com.esri.arcgis.server.IServerContext;
import com.esri.arcgis.server.IServerObjectManager;
import com.esri.arcgis.server.ServerConnection;

public class CreateAO {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws UnknownHostException 
	 */
	public static void main(String[] args) throws UnknownHostException, IOException {
		// TODO Auto-generated method stub
		ServerConnection conn = new ServerConnection(); 
		conn.connect("192.168.3.106", "*", "zhushijie", "zsj123456");
		                
		IServerObjectManager som = conn.getServerObjectManager();
		IServerContext severContext = som.createServerContext("", "");
		MapDocument mapDoc = (MapDocument) severContext.createObject(MapDocument.getClsid());
		mapDoc.esri_new("c:\\temp\\helloMXD2.mxd");
		mapDoc.close();
		severContext.removeAll();
		severContext.releaseContext();
		conn.release();
		System.out.println("Congratulaction!");
	}

}
